<template>
  <div class="mod-config">
    <table-view ref="view"
                :searchAttrs="searchAttrs"
                :primaryKey="primaryKey"
                :listApiName="listApiName"
                :deleteApiName="deleteApiName"
                :saveAuthName="saveAuthName"
                :deleteAuthName="deleteAuthName"
                :showAttrs="showAttrs"
                :optionWidth="200"
    >
      <template v-slot:foot="{scope}">
        <el-button size="small" type="text" @click="exportPlan(R.path(['row', primaryKey], scope))">
          导出
        </el-button>
      </template>
    </table-view>
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  </div>
</template>

<script>
import AddOrUpdate from './productplannotice-add-or-update'
import tableView from '@/components/tableView'
import basicMixins from '@/utils/commonViewMixins'
import {exportHandle} from '@/utils'

export default {
  mixins: [basicMixins],
  data() {
    return {
      searchAttrs: {
        productId: {
          type: 'autoComplete',
          placeholder: '请选择产品',
          querySearchApiName: 'productApi/getProductInfoList'
        },
        orderDetailId: {
          type: 'autoComplete',
          placeholder: '请输入订单编号',
          querySearchApiName: 'orderApi/getOrderDetailList'
        },
        productWeight: {
          label: '产品重量',
          placeholder: '请输入产品重量',
          inputType: 'number'
        },
        dateTimeRange: {
          type: 'date',
          dateType: 'daterange',
          clearable: true
        }
      },
      primaryKey: 'id',
      listApiName: 'productApi/listProductPlanNotice',
      deleteApiName: 'productApi/deleteProductPlanNotice',
      saveAuthName: 'product:productplannotice:save',
      deleteAuthName: 'product:productplannotice:delete',
      showAttrs: {
        orderNo: {label: '订单编号',width:150},
        productNo: {label: '产品编号',width:100},
        modelNo: {label: '模具编号'},
        deviceNo: {label: '设备编号'},
        productWeight: {label: '产品重量'},
        productVolume: {label: '容量'},
        orderProductNumber: {label: '订单数量'},
        dayTime: {label: '日期', type: 'date'},
        //classesName: {label: '换产班组'},
        nextProductNo: {label: '换产产品编号'},
        nextProductNumber: {label: '换产数量'},
        remark: {label: '备注'},
        status: {
          label: '状态',
          type: 'radio',
          items: [
            {value: 0, text: '禁用', tagType: 'danger'},
            {value: 1, text: '正常'}
          ]
        },
        qualityGrade: {
          label: '质量等级',
          type: 'radio',
          items: [
            {value: 0, text: 'A'},
            {value: 1, text: 'B'}
          ]
        },
        bottleCapSuit: {
          label: '套装',
          type: 'radio',
          items: [
            {value: 0, text: '无', tagType: 'danger'},
            {value: 1, text: '有'}
          ]
        },
        deepTypeList: {label: '后序加工'},
        groupNumber: {label: '组数'},
        packRequire: {label: '包装要求'},
        boxNo: {label: '纸箱编号'},
        customerRequire: {label: '客户质量要求'},
        bottleHeight: {label: '瓶身总高度'},
        bottleInDiameter: {label: '瓶口内径'},
        headNeckHeight: {label: '头颈高度'},
        bottleOutDiameter: {label: '瓶口外径'},
        customerProductStyle: {
          label: '定制化要求',
          type: 'radio',
          items: [
            {value: 0, text: '无', tagType: 'danger'},
            {value: 1, text: '有'}
          ]
        }
      }
    }
  },
  methods: {
    exportPlan(id) {
      exportHandle('productApi/getProductPlanNoticeExport', {productPlanNoticeId: id})
    }
  },
  components: {
    AddOrUpdate,
    tableView
  }
}
</script>
